<?php 
//引入头部和常用函数
include_once '../function.php';

//实例化msyqli类
$mysqli = @new mysqli("localhost", "root", "", "school"); 

if($mysqli->connect_errno){
	echo "数据链接失败：错误代码：".$mysqli->connect_errno."错误信息：".$mysqli->connect_error;
}


$mysqli->query("set names utf8");


$sql = "select * from stu";

// $sql = "update stusdf set sex='女' where id ='12'";


$res = $mysqli->query($sql);

if(!$res){
	echo "执行失败：错误代码：".$mysqli->errno."错误信息：".$mysqli->error;
}

// var_dump($res->fetch_assoc());
// var_dump($res->fetch_assoc());
// var_dump($res->fetch_assoc());
// var_dump($res->fetch_assoc());

$tempArr = [];
//循环获取结果集中的资源 
while ($row = $res->fetch_assoc()) {
	$tempArr[]=$row;
}

var_dump($tempArr);

//释放结果集
$res->free();

//关闭链接
$mysqli->close();






 ?>